package com.wondedDream.controller.web;

import com.wondedDream.model.PracticeQuestion;
import com.wondedDream.model.UserPracticeRecord;
import com.wondedDream.service.UserPracticeRecordService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController(value = "webUserPracticeRecordController")
@RequestMapping("/web/userPracticeRecords")
@Api(description = "客户端-用户练习习题记录模块")
public class UserPracticeRecordController {

    @Autowired
    private UserPracticeRecordService userPracticeRecordService;

    // 创建新的用户练习记录
    @PostMapping("/")
    public UserPracticeRecord createUserPracticeRecord(@RequestBody UserPracticeRecord record) {
        return userPracticeRecordService.saveUserPracticeRecord(record);
    }

    // 获取某一练习问题的所有用户练习记录
    @GetMapping("/byPracticeQuestion/{practiceQuestionId}")
    public List<UserPracticeRecord> getUserPracticeRecordsByPracticeQuestionId(@PathVariable Integer practiceQuestionId) {
        return userPracticeRecordService.getUserPracticeRecordsByPracticeQuestionId(practiceQuestionId);
    }

}